package com.ssm.xml.service.impl;

import com.ssm.xml.entity.Article;
import com.ssm.xml.mapper.ArticleMapper;
import com.ssm.xml.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Charles
 * @date 2022/4/27 0027 23:02
 */

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public List<Article> getAllArticleByDir(int DirId) {
        Map<String,Object> condition = new HashMap<>();
        condition.put("belong", DirId);
        return articleMapper.selectByMap(condition);
    }

    @Override
    public void deleteArticle(int id) {
        articleMapper.deleteById(id);
    }

    @Override
    public void addArticle(Article article) {
        articleMapper.insert(article);
    }

    @Override
    public void updateArticle(Article article) {
        articleMapper.updateById(article);
    }
}
